$(()=> {
  // get dom elem
  let $width = $('#width'),
      $height = $('#height'),
      $btnCal = $('#calc'),
      $perimeter = $('#perimeter'),
      $area = $('#area');

  // 浮点摄入误差
  function roundFractional(x, n) {
    return Math.round(x * Math.pow(10, n)) / Math.pow(10, n);
  }

  // calc button clich
  $btnCal.click(()=> {
    // get value
    let w = Number($width.val()),
        h = Number($height.val());
    // calc
    let p = (w + h) * 2,
        a = w * h;
    //output
    $perimeter.val(roundFractional(p,2));
    $area.val(roundFractional(a,2));
  });
});
